CXX     = $(CROSS_COMPILE)g++
CC      = $(CROSS_COMPILE)gcc
AR      = $(CROSS_COMPILE)ar
LD      = $(CROSS_COMPILE)ld
STRIP   = $(CROSS_COMPILE)strip
OBJDUMP = $(CROSS_COMPILE)objdump
NM      = $(CROSS_COMPILE)nm

LIBRARIES := libfdt.so
LIB_SRC := fdt_channel.c \
	       fdt_shmmgr.c \
		   fdt_daemon.c \
		   fdt_net.c \
		   fdt_vector.c

LIB_OBJ := $(patsubst %.c, %.o, $(LIB_SRC))

PROG := ulayer llayer

all: $(LIBRARIES) 

CFLAGS   := -g -fPIC -I../export
CPPFLAGS := 
LDFLAGS  := -L.

$(LIBRARIES): $(LIB_OBJ)
	$(CC) -shared $(LDFLAGS) -o $(LIBRARIES) $(LIB_OBJ)

%.o : %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

.PHONY: test clean

test: $(PROG)

ulayer: ulayer.o $(LIBRARIES)
	$(CC) $(LDFLAGS) $< -o $@ -lfdt 

llayer: llayer.o $(LIBRARIES)
	$(CC) $(LDFLAGS) $< -o $@ -lfdt 

clean:
	rm -f *.o *.so $(PROG)

